package com.zxl.live.tools.anim;

import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.Transformation;

/**
 * Created by Administrator on 2017/6/23.
 */

public class CollapseAnimation extends Animation {

    private View mView;

    private int fromHeight;

    private int toHeight;


    public CollapseAnimation(View view, int fromHeight, int toHeight) {
        mView = view;
        this.fromHeight = fromHeight;
        this.toHeight = toHeight;
    }

    @Override
    protected final void applyTransformation(float paramFloat, Transformation paramTransformation) {
        ViewGroup.LayoutParams localLayoutParams = mView.getLayoutParams();
        localLayoutParams.height = (int) (fromHeight - (fromHeight - toHeight) * paramFloat);
        this.mView.requestLayout();
    }

    @Override
    public final boolean willChangeBounds() {
        return true;
    }

}
